/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package snippet.lab2;

/**
 *
 * @author hoang.pt
 */
public class Drawing implements Runnable{

    String name;

    int deposit;

    Account acc;

    Thread t;

    /**
     * 
     * @param String name
     * @param int deposit
     * @param Account acc
     */
    public Drawing(String name, int deposit, Account acc) {
        this.name = name;
        this.deposit = deposit;
        this.acc = acc;

        Thread t = new Thread(this);
        t.start();
    }


    
    /**
     * Override method
     */
    public void run() {
        //draw money
        try {
            acc.drawMoney(name, deposit);

            //print .....
            for (int i=0; i<5; i++ ) {
                Thread.sleep(1000);
                System.out.print(".");
            }

            System.out.print("\n");
            System.out.println("Now balance is " + acc.balance);

        } catch(InterruptedException ex) {
            ex.printStackTrace();
        }

        //throw new UnsupportedOperationException("Not supported yet.");
    }


    
}
